package com.multi.thread.chapter01;

public class SuspendThread {
	
	synchronized public void pringString() {
		System.out.println("begin!");
		if (Thread.currentThread().getName().equals("a")) {
			System.err.println("a 线程永远suspend了!");
			Thread.currentThread().suspend();
		}
		System.out.println("end!");
	}
	
	public static void main(String[] args) throws InterruptedException {
		final SuspendThread obj = new SuspendThread();
		Thread thread1 = new Thread() {
			@Override
			public void run() {
				obj.pringString();
			}
		};
		thread1.setName("a");
		thread1.start();
		Thread.sleep(5000);
		
		Thread thread2 = new Thread() {
			@Override
			public void run() {
				System.out.println("thread2启动了，但进入不了printString()方法，只打印了一个begin!");
				System.out.println("因为printString()方法被a线程锁定并且永远suspend暂停了!");
			}
		};
		thread2.start();
	}

}
